﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using System.Reflection;
using log4net;

namespace AnyOffice.general.email
{
    public partial class change_box : ModulePage
    {

        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

 
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = (Request.QueryString["id_str"] != null) ? Request.QueryString["id_str"].ToString() : "";
            int boxId = (Request.QueryString["box_id"] != null) ? int.Parse(Request.QueryString["box_id"].ToString()) : 0;
            int num2 = (Request.QueryString["old_id"] != null) ? int.Parse(Request.QueryString["old_id"].ToString()) : 0;
            int num3 = (Request.QueryString["page"] != null) ? int.Parse(Request.QueryString["page"].ToString()) : 1;
            if (str != string.Empty)
            {
                if (str.EndsWith(","))
                {
                    str = str.Substring(0, str.Length - 1);
                }
                string[] strArray = str.Split(new char[] { ',' });
                if (strArray.Length > 0)
                {
                    EmailDao dao = new EmailDao();
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        try
                        {
                            dao.ChangeBox(base.Conn, Convert.ToInt32(strArray[i]), boxId, base.User.Identity.Name);
                        }
                        catch (Exception exception)
                        {
                            if (log.IsErrorEnabled)
                            {
                                log.Error("", exception);
                            }
                        }
                    }
                }
            }
            Response.Redirect("inbox.aspx?box_id=" + num2.ToString() + "&page=" + num3.ToString());
        }

    }
}
